<extend name="Public:mainbase" />
<block name="content">
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-switch.min.css">
    <script src="__PUBLIC__/js/bootstrap-switch.min.js" type="text/javascript"></script>

    <form action="{:U('updateBlock')}" method="post">
        <div class="panel panel-default">
            <div class="panel-body">
                <form name="form2" method="post">
                    <table width="98%" class="table table-bordered  table-hover table-condensed "  align="center">
                        <tr bgcolor="#E7E7E7" >
                            <td height="28" colspan="11" background="__PUBLIC__/images/tbg.gif" style="padding-left:10px;">
                                ◆ 版本列表 &nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="btn btn-xs btn-warning" data-toggle="modal" data-target=".newblockbox"><i class="glyphicon glyphicon-plus"></i> 添加功能锁</button>
                            </td>
                        </tr>
                        <tr align="center" bgcolor="#FBFCE2" height="25">
                            <td width="6%">ID</td>
                            <td width="10%">模块</td>
                            <td width="10%">方法</td>
                            <td width="10%">IOS版本</td>
                            <td width="10%">Android版本</td>
                            <td width="10%">操作</td>
                        </tr>
                        <foreach name="vList" item="val">
                            <tr align='center' bgcolor="#FFFFFF" height="26">
                                <td nowrap>{$val.id}</td>
                                <td><?php echo $module[$val['module']];?>({$val.module})</td>
                                <td><?php echo $action[$val['action']];?>({$val.action})</td>
                                <td>{$val.ios_vers}</td>
                                <td>{$val.android_vers}</td>
                                <td>
                                    <a href="javascript:;" data-id='{$val.id}' class='editblock'>修改</a>
                                    |
                                    <a href="javascript:;" data-id='{$val.id}' class='delblock'>删除</a>
                                </td>
                            </tr>
                        </foreach>
                        <tr bgcolor="#ffffff">
                            <td height="36" colspan="11">
                                &nbsp;
                                <a href="javascript:selAll()" class="btn btn-xs btn-info"><i class='glyphicon glyphicon-ok'></i> 全选</a>
                                <a href="javascript:noSelAll()" class="btn btn-xs btn-info"><i class='glyphicon glyphicon-remove'></i> 取消</a>
                                <!-- <a href="javascript:checkArc(0)" class="btn btn-xs btn-info">&nbsp;审核&nbsp;</a> -->
                                <a href="javascript:;" id="delversionall" class="btn btn-xs btn-info"><i class="glyphicon glyphicon-trash"></i> 删除</a>
                            </td>
                        </tr>
                </form>
                <tr align="right" bgcolor="#F9FCEF">
                    <td height="36" colspan="11" align="center">
                        <span>{$showpage}</span>
                    </td>
                </tr>
                </table>



            </div>

        </div>
    </form>
    <!-- 添加组弹窗 -->
    <div class="modal fade newblockbox" tabindex="-1" Auth="dialog" aria-labelledby="add_user_jump" id='newblockbox'>
        <div class="modal-dialog modal-sm" style="width:40%">

            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">添加组信息</h4>
                </div>
                <form action="{:U('add')}" method="POST" class="form-horizontal" id="adduserform" style="padding:15px 0" enctype="multipart/form-data">
                    <div class="form-group">
                        <label for="module" class="col-sm-2 control-label">模块名</label>
                        <div class="col-sm-5">
                        	<select name="module" placeholder="请输入模块名" nullmsg="请选择模块名" class="form-control">
                        		<option value="">--请选择模块名--</option>
                        		<option value="article">文稿</option>
                        		<option value="live">直播</option>
                        	</select>
                        </div>
                        <div class="col-sm-5"></div>
                    </div>

                    <div class="form-group">
                        <label for="action" class="col-sm-2 control-label">方法名</label>
                        <div class="col-sm-5">
                        	<select name="action" placeholder="请输入方法名" nullmsg="请选择方法名" class="form-control">
                        		<option value="">--请选择方法名--</option>
                        		<option value="add">发布</option>
                        		<option value="edit">修改</option>
                        		<option value="view">查看</option>
                        		<option value="delete">删除</option>
                        	</select>
                        </div>
                        <div class="col-sm-5"></div>
                    </div>


                    <div class="form-group">
                        <label for="ios_vers" class="col-sm-2 control-label">IOS版本</label>
                        <div class="col-sm-5">
                            <select class="form-control" name="ios_min_vers_id" nullmsg="请选择IOS版本">
                                <option value="">--请选择IOS版本--</option>
                                <?php foreach($ios_vers_list as $key => $val) { ?>
                                <option value="{$val.id}">{$val.version}</option>
                                <?php } ?>
                            </select>
                        </div>
                        <div class="col-sm-5"></div>
                    </div>



                    <div class="form-group">
                        <label for="android_vers" class="col-sm-2 control-label">Android版本</label>
                        <div class="col-sm-5">
                            <select class="form-control" name="android_min_vers_id" nullmsg="请选择Android版本">
                                <option value="">--请选择Android版本--</option>
                                <?php foreach($android_vers_list as $key => $val) { ?>
                                <option value="{$val.id}">{$val.version}</option>
                                <?php } ?>
                            </select>
                        </div>
                        <div class="col-sm-5"></div>
                    </div>


                    <div class="form-group">
                        <label class="col-sm-2 control-label">介绍标题</label>
                        <div class="col-sm-5"><input type="text" class="form-control" name="title"></div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">介绍</label>
                        <div class="col-sm-5"><textarea cols="60" rows="5"  class="form-control" name="intro"></textarea></div>
                    </div>

                    <div class="add-error-message error item"></div>

                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-success">确定添加</button>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <button type="button" class="btn btn-danger"  data-dismiss="modal">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!-- 修改组弹窗 -->
    <div class="modal fade editblockbox" tabindex="-1" Auth="dialog" aria-labelledby="add_user_jump" id='editblockbox'>
        <div class="modal-dialog modal-sm" style="width:40%">

            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">添加组信息</h4>
                </div>
                <form action="{:U('edit')}" method="POST" class="form-horizontal" id="adduserform" style="padding:15px 0" enctype="multipart/form-data">
                    <input name='id' type="hidden" value=''>
                    <div class="form-group">
                        <label for="module" class="col-sm-2 control-label">模块名</label>
                        <div class="col-sm-5">
                            <select name="module" placeholder="请输入模块名" nullmsg="请选择模块名" class="form-control">
                        		<option value="">--请选择模块名--</option>
                        		<option value="article" >文稿</option>
                        		<option value="live">直播</option>
                        	</select>
                        </div>
                        <div class="col-sm-5"></div>
                    </div>

                    <div class="form-group">
                        <label for="action" class="col-sm-2 control-label">方法名</label>
                        <div class="col-sm-5">
                           <select name="action" placeholder="请输入方法名" nullmsg="请选择方法名" class="form-control">
                        		<option value="">--请选择方法名--</option>
                        		<option value="add">发布</option>
                        		<option value="edit">修改</option>
                        		<option value="view">查看</option>
                        		<option value="delete">删除</option>
                        	</select>
                        </div>
                        <div class="col-sm-5"></div>
                    </div>


                    <div class="form-group">
                        <label for="ios_vers" class="col-sm-2 control-label">IOS版本</label>
                        <div class="col-sm-5">
                            <select class="form-control" name="ios_min_vers_id">
                                <?php foreach($ios_vers_list as $key => $val) { ?>
                                <option value="{$val.id}">{$val.version}</option>
                                <?php } ?>
                            </select>
                        </div>
                        <div class="col-sm-5"></div>
                    </div>


                    <div class="form-group">
                        <label for="android_vers" class="col-sm-2 control-label">Android版本</label>
                        <div class="col-sm-5">
                            <select class="form-control" name="android_min_vers_id">
                                <?php foreach($android_vers_list as $key => $val) { ?>
                                <option value="{$val.id}">{$val.version}</option>
                                <?php } ?>
                            </select>
                        </div>
                        <div class="col-sm-5"></div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">介绍标题</label>
                        <div class="col-sm-5"><input type="text" class="form-control" name="title"></div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">简介</label>
                        <div class="col-sm-5"><textarea cols="60" rows="5"  class="form-control" name="intro"></textarea></div>
                    </div>

                    <div class="add-error-message error item"></div>

                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-success">确定修改</button>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <button type="button" class="btn btn-danger"  data-dismiss="modal">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        $('.editblock').click(function(){
            $('#editblockbox form').get(0).reset();
            $.get("{:U('ajaxGetBlockInfo')}?id="+$(this).data('id'),function(data){
                if(data!=0){
                    $("#editblockbox [name=id]").val(data.id);
                    $("#editblockbox [name=module]").val(data.module);
                    $("#editblockbox [name=action]").val(data.action);
                    $("#editblockbox [name=ios_min_vers_id]").val(data.ios_min_vers_id);
                    $("#editblockbox [name=android_min_vers_id]").val(data.android_min_vers_id);
                    $("#editblockbox [name=intro]").val(data.intro);
                    $("#editblockbox [name=title]").val(data.title);
                    //$("#edit-status_" + data.is_open).get(0).checked=true;
                    $('#editblockbox').modal('show');
                }
            })
            $('#editblockbox .Validform_checktip').empty().attr('class','Validform_checktip');
            $('.Validform_error').removeClass('Validform_error');

        })

        $('.delblock').click(function(){
            if(confirm('是否确定删除此功能锁？')){
                var obj=this;
                $.get('{:U("ajaxdelblock")}?id='+$(obj).data('id'),function(data){
                    if(data==1){
                        $(obj).parents('tr').remove();
                    }
                })
            }
        })

    </script>
</block>